#include <stdio.h>
#include<math.h>

int main()
{
    int a, b, x, y, temp;
    scanf("%d%d%d%d", &a, &b, &x, &y);
    if (abs(a - x) > abs(a - y))
    {
        temp = x;
        x = y;
        y = temp;
    }
    int step1 = (a - x > 0 ? a - x : x - a);
    int step2 = (b - y > 0 ? b - y : y - b);
    int sum1 = step1 + step2;
    int sum2 = abs(a - b);
    if (sum1 < sum2)
    {
        printf("%d\n", sum1);
    }
    else
    {
        printf("%d\n", sum2);
    }
    return 0;
}